<?php

namespace Lettral\LetterBundle\Controller;

use Lettral\Helpers\ResponseCreator;

use Lettral\Helpers;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use \Symfony\Component\HttpFoundation\Response;

class AdresseEntController extends Controller
{
    public function listAction()
    {
    	$em = $this->container->get('doctrine')->getEntityManager();	
    	$query = $em->createQuery("SELECT address.nom as label, address.nom as value, address.compNom1, address.compNom2, address.adresse, address.cp, address.ville FROM LettralLetterBundle:AdresseEnt address");
    	$adresses = $query->getResult();
    	
    	$response = new \Symfony\Component\HttpFoundation\Response();   	
    	$response->headers->set('Content-Type', 'application/json; charset=UTF-8');
    	$response->setContent(json_encode($adresses));
    	
    	return $response;
    }
    
}
